//
//  MineHeadView.m
//  XingRun
//
//  Created by 赵颜彬 on 17/1/13.
//  Copyright © 2017年 赵颜彬. All rights reserved.
//

#import "MineHeadView.h"
@interface MineHeadView()<UICollectionViewDelegate, UICollectionViewDataSource>

@property (nonatomic, strong)UILabel *name;

@property (nonatomic, strong)UILabel *Sex;

@property (nonatomic, strong)UILabel *age;

@property (nonatomic, strong)UIImageView *img;

@property (nonatomic, strong)UIImageView *Jiantou;

@property (nonatomic, strong)UICollectionView *collect;

@end

static NSString *MineCollectionViewCellId = @"MINECOLLECTIONVIEWCELLID";
@implementation MineHeadView


- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.name = [[UILabel alloc] init];
        self.name.text = @"用户名";
        self.name.font = [UIFont fontWithName:@"Helvetica" size:15];
        [self addSubview:_name];
        
        self.Sex = [[UILabel alloc] init];
        self.Sex.text = @"性别";
        self.Sex.font = [UIFont fontWithName:@"Helvetica" size:12];
        [self addSubview:_Sex];
        
        self.age = [[UILabel alloc] init];
        self.age.text = @"年龄";
        self.age.font = [UIFont fontWithName:@"Helvetica" size:12];
        [self addSubview:_age];
        
        self.img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"占位图"]];
        [self addSubview:_img];
        
        self.Jiantou =  [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"箭头"]];
        [self addSubview:_Jiantou];
        
        UICollectionViewFlowLayout *flowLayout=[[UICollectionViewFlowLayout alloc] init];
        [flowLayout setSectionInset:UIEdgeInsetsMake(0 * HEIGHT, 0, 0 * HEIGHT, 0)];
        flowLayout.itemSize = CGSizeMake(375 * WIDTH / 3, 50 * HEIGHT);
        
        [flowLayout setHeaderReferenceSize:CGSizeMake(self.frame.size.width, 217 * HEIGHT)];
        
        [flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
        // 宽
        [flowLayout setMinimumInteritemSpacing:0 ];
        //高
        [flowLayout setMinimumLineSpacing:0 * HEIGHT];
        self.collect = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 100, self.frame.size.width, 50 * HEIGHT) collectionViewLayout:flowLayout];
        self.collect.backgroundColor = [CGLTool hexStringToColor:@"#f9f9f9"];
          [_collect registerClass:[MineTableViewCell class] forCellWithReuseIdentifier:MineCollectionViewCellId];
        //代理设置
        _collect.delegate=self;
        _collect.dataSource=self;
        [self addSubview:_collect];

    }
    return self;
}
//返回分区个数
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}
//返回每个分区的item个数
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
        return 3;
}
//返回每个item
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    

        MineTableViewCell * cell  = [collectionView dequeueReusableCellWithReuseIdentifier:MineCollectionViewCellId forIndexPath:indexPath];
        cell.name.text = @"wowowo";
        cell.imgView.text = @"wowowowowo";
        return cell;
    
}


- (void)layoutSubviews{
    [super layoutSubviews];
    _img.frame = CGRectMake(20 * WIDTH, 20 * HEIGHT, 70 * WIDTH, 70 * HEIGHT);
    _name.frame =  CGRectMake(100 * WIDTH, 20 * HEIGHT, 50 * WIDTH, 30 * HEIGHT);
    _Sex.frame =  CGRectMake(100 * WIDTH, 60 * HEIGHT, 50 * WIDTH, 30 * HEIGHT);
    _age.frame =  CGRectMake(140 * WIDTH, 60 * HEIGHT, 50 * WIDTH, 30 * HEIGHT);
    _Jiantou.frame = CGRectMake(350 *WIDTH, 50 * HEIGHT, 8 * WIDTH, 16 * HEIGHT);
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
